<?php
function getDocumentRoot()
{
    $returnPath = "";
    if(false !== strpos($_SERVER['DOCUMENT_ROOT'], 'PEAR') ) {
        $returnPath = $_SERVER['DOCUMENT_ROOT'];
    } else {
        $returnPath = 'D:/Programme/Xampp/htdocs/BuildBase/';
    }
    return $returnPath;
}

function __autoload($class) {
//    echo "<br>autoload with $class";

    if (!file_exists(getDocumentRoot() . $class . ".php")) {//false === require_once($class . ".php")) {
        if (!file_exists(getDocumentRoot() . "includes/" . $class . ".php")) {//false === require_once(getDocumentRoot() . "includes/" . $class . ".php")) {
        } else {
            require_once(getDocumentRoot() . "includes/" . $class . ".php");
        }
    } else {
        require_once($class . ".php");
    }

    if (!class_exists($class)) {//true === strchr($class, "_")) {
        error_log("\n bingo bongo \n");
        $class = str_replace("_","/", $class);
        error_log("\n in here" . getDocumentRoot() . $class . "\n");
        if (!file_exists(getDocumentRoot() . $class . ".php")) {//false === require_once($class . ".php")) {
            if (!file_exists(getDocumentRoot() . "includes/" . $class . ".php")) {//false === require_once(getDocumentRoot() . "includes/" . $class . ".php")) {
                die('no file has been found arround');
            } else {
                require_once(getDocumentRoot() . "includes/" . $class . ".php");
            }
        } else {
            require_once($class . ".php");
        }
    }
}

header("Cache-Control: no-cache");
header("Pragma: no-cache");

define('SMARTY_DIR', getDocumentRoot() . 'smarty/');
require_once(SMARTY_DIR . 'Smarty.class.php');
spl_autoload_register('__autoload');


//echo getDocumentRoot();
    